﻿#define _CRT_SECURE_NO_WARNINGS 1


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmp(int* a, int* b)//判断字母数量是否相同
{
    for (int i = 0; i < 26; i++)
    {
        if (a[i] != b[i])
            return 1;
    }
    return 0;
}

int main()
{
    char arr[1000][10] = { 0 };
    int n = 0;
    int count = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%s", &arr[i]);
    char word[10] = { 0 };
    scanf("%s", word);
    int k = 0;
    scanf("%d", &k);
    int len_word = strlen(word);
    int hashmap_word[26] = { 0 };
    int hashmap[26] = { 0 };
    for (int i = 0; i < len_word; i++)
    {
        hashmap_word[word[i] - 'a']++;
    }
    for (int i = 0; i < n; i++)
    {
        int len = strlen(arr[i]);
        if (len == len_word && strcmp(word, arr[i]) != 0)
        {
            for (int j = 0; j < len; j++)
            {
                hashmap[arr[i][j] - 'a']++;
            }
        }


        if (cmp(hashmap, hashmap_word))
            arr[i][0] = '~';//只要比z大就行，目的是让字符串排到兄弟单词的后面
        else
            count++;
        memset(hashmap, 0, sizeof(int) * 26);
    }

    for (int i = 0; i < n; i++)//排序，交换
    {
        for (int j = 0; j < n - i - 1; j++)
        {
            if (strcmp(arr[j], arr[j + 1]) > 0)
            {
                char tmp[10] = { 0 };
                memcpy(tmp, arr[j], 10);
                memcpy(arr[j], arr[j + 1], 10);
                memcpy(arr[j + 1], tmp, 10);
            }
        }
    }

    printf("%d\n", count);
    if (k < count + 1)
        printf("%s", arr[k - 1]);
    return 0;
}